import Vue from 'vue'
import VueRouter from 'vue-router'
import login from '../pages/login.vue'
import Layout from '../views/layout.vue'

import Home from '../views/home/home.vue'
import question from '../views/question.vue'
import user from '../views/user'
import video from '../views/video.vue'
import search from '@/pages/search'
import result from '@/pages/search/result'
import article from '../views/article'

Vue.use(VueRouter)

const routes = [
  {
    path: '/login',
    name: 'login',
    component: login
  },
  {
    path: '/',
    name: 'layout',
    component: Layout,
    children: [
      { path: '', component: Home, meta: { isKeepAlive: true } },
      { path: '/question', component: question },
      { path: '/user', component: user },
      { path: '/video', component: video }
    ]
  },
  {
    path: '/search',
    name: 'search',
    component: search
  },
  {
    path: '/search/result',
    name: 'result',
    component: result
  },
  {
    path: '/article/:id',
    name: 'article',
    component: article
  },
  {
    path: '/user/profile',
    name: 'userProfile',
    component: () => import('@/views/user/profile')
  },
  {
    path: '/user/chat',
    name: 'chat',
    component: () => import('../views/user/chat')
  }
]

const router = new VueRouter({
  routes
})

export default router
